Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

260
Views
Node/Express: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type function ([Function (anonymous)])

I'm building a server with Node and Express, using handlebars as views. My controller contains the system logic functions, which receive the request and response objects as parameters and my Route, only makes the connection between the route and the controller. But I am not able to see the error to generate this error in the title.

My controller.js:

const router = express.Router();

exports.home = (req, res) => {
    res.render('home', { entries: entries });
};

exports.Form = (req, res) =>{
    res.render('form')
};

exports.FormFetch = (req, res) =>{
    res.render('form-fetch')
};

My app.js:

const express = require('express');
const handlebars = require('express-handlebars');

const app = express();

app.engine('.hbs', handlebars.engine({
  defaultLayout: 'main',
  extname: '.hbs',
}));

app.set('view engine', '.hbs')

app.use(express.urlencoded({ extended: false }));
app.use(express.json());

var userRoute = require('./routes')

app.get('/', userRoute)
app.use('/new-entry', userRoute)
app.use('/new-entry-fetch', userRoute)

app.listen(3000, () =>{
    console.log('Ok')
});

My routes.js:

const express = require('express');
const controller = require('./controllers/controllers');
const app = express();

const entries = [];

app.get('/', (req, res) => {
    res.render(controller.home, { entries: entries });
});

app.get('/new-entry', (req, res) => {
    res.render(controller.Form);
});

app.get('/new-entry-fetch', (req, res) => {
    res.render(controller.FormFetch);
});

app.post('/new-entry', (req, res) => {
    entries.push({
        title: req.body.title,
        content: req.body.body,
        published: new Date()
    });

    res.redirect(303, '/');
});

module.exports = app
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!